package com.wzp.util.http;

import com.wzp.util.collection.CollectionUtils;
import com.wzp.util.json.JsonUtils;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;

public class HttpUtilTest1 {

    public static void main(String[] args) throws Exception {
        FileInputStream inputStream = null;
        try {
//            inputStream = new FileInputStream("/Users/wangzhengpeng/Desktop/Text/text_line.txt");
//            inputStream = new FileInputStream("/Users/wangzhengpeng/Desktop/Text/text_line_ota.txt");
            inputStream = new FileInputStream("/Users/wangzhengpeng/Desktop/Text/text1.txt");
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        }
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));

        String str = null;
        int count  = 0;
        for (int i = 0; i < 100000; i++) {
            Thread.sleep(10);
            try {
                if (!((str = bufferedReader.readLine()) != null)) break;
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
//            String doPost = HttpUtil.doPost("http://10.68.48.52:8080/test/ticket/ticketBooking", str);
//            String doPost = HttpUtil.doPost("http://10.68.112.92:8080/test/xotasearch1", str);
            String doPost = HttpUtil.doPost("http://10.93.66.40:8080/test/combineBooking1", str);
//            String doPost = HttpUtil.doPost("http://10.68.112.92:8080/test/listSearchV2", str);
//            String doPost = HttpUtil.doPost("http://10.66.77.141:8080/test/secondSaleTestV2", str);
//            String doPost = HttpUtil.doPost("http://10.80.2.13:8080/test/secondSaleTestV2", str);
//            String doPost = HttpUtil.doPost("http://10.68.52.186:8080/test/xOtaTransferRoundSearch", str);
//            String doPost = HttpUtil.doPost("http://10.80.1.239:8080/debug/inter/interSecondSale", str);

//            System.out.println("doReq = " + str);
//            String doPost = HttpUtil.doPost("http://10.68.18.100:8080/test/search", str);
//            String doPost = HttpUtil.doPost("http://10.68.35.65:8080/test/booking", str);
            XCombineBookingResult xCombineBookingResult = JsonUtils.parseObject(doPost, XCombineBookingResult.class);

            if (CollectionUtils.isEmpty(xCombineBookingResult.getCombineXData())) {
                count++;
            }
//            if (doPost.contains("inter_second_ins")) {
//            System.out.println("req: " + str + "doPost " + doPost);
            System.out.println("i = " + i + "=========== count = " + count);

//            }
        }
        System.out.println("最终count = "+ count);
    }

}
